home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / QuickTime VR / MacOS / QuickDraw™ 3D 1.0.6F4 SDK / Development / Interfaces / QD3DMath.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-14  |  24.2 KB  |  891 lines  |  [TEXT/MPS ]

  1. /******************************************************************************
  2.  **                                                                             **
  3.  **     Module:        QD3DMath.h                                                 **
  4.  **                                                                          **
  5.  **                                                                          **
  6.  **                                                                          **
  7.  **     Purpose:     Math & matrix routines and definitions.                     **
  8.  **                                                                          **
  9.  **                                                                          **
  10.  **     Copyright (C) 1992-1995 Apple Computer, Inc.  All rights reserved.     **
  11.  **                                                                          **
  12.  **                                                                          ** 
  13.  *****************************************************************************/
  14. #ifndef QD3DMath_h
  15. #define QD3DMath_h
  16.  
  17. #ifndef QD3D_h
  18. #include <QD3D.h>
  19. #endif  /*  QD3D_h  */
  20.  
  21. #if PRAGMA_ONCE
  22.     #pragma once
  23. #endif
  24.  
  25. #if defined(__MWERKS__)
  26.     #pragma enumsalwaysint on
  27.     #pragma align_array_members off
  28.     #pragma options align=native
  29. #endif
  30.  
  31. #include <math.h>
  32. #include <float.h>
  33.  
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif    /* __cplusplus */
  37.  
  38. /******************************************************************************
  39.  **                                                                             **
  40.  **                            Constant Definitions                             **
  41.  **                                                                             **
  42.  *****************************************************************************/
  43. /*
  44.  *  Real zero definition
  45.  */
  46. #ifdef FLT_EPSILON
  47. #    define kQ3RealZero            (FLT_EPSILON)
  48. #else
  49. #    define kQ3RealZero            ((float)1.19209290e-07)            
  50. #endif  /*  FLT_EPSILON  */
  51.  
  52. #ifdef FLT_MAX
  53. #    define    kQ3MaxFloat            (FLT_MAX)
  54. #else
  55. #    define    kQ3MaxFloat            ((float)3.40282347e+38)
  56. #endif  /*  FLT_MAX  */
  57.  
  58. /*
  59.  *  Values of PI
  60.  */
  61. #define kQ3Pi                     ((float)3.1415926535898)
  62. #define kQ32Pi                     ((float)(2.0 * 3.1415926535898))
  63. #define kQ3PiOver2                ((float)(3.1415926535898 / 2.0))
  64. #define kQ33PiOver2                ((float)(3.0 * 3.1415926535898 / 2.0))
  65.  
  66.  
  67. /******************************************************************************
  68.  **                                                                             **
  69.  **                            Miscellaneous Functions                             **
  70.  **                                                                             **
  71.  *****************************************************************************/
  72.  
  73. #define Q3Math_DegreesToRadians(x)    ((float)((x) *  kQ3Pi / 180.0))
  74. #define Q3Math_RadiansToDegrees(x)    ((float)((x) * 180.0 / kQ3Pi))
  75.  
  76. #define Q3Math_Min(x,y)                ((x) <= (y) ? (x) : (y))
  77. #define Q3Math_Max(x,y)                ((x) >= (y) ? (x) : (y))
  78.  
  79.         
  80. /******************************************************************************
  81.  **                                                                             **
  82.  **                            Point and Vector Creation                         **
  83.  **                                                                             **
  84.  *****************************************************************************/
  85.  
  86. QD3D_EXPORT TQ3Point2D *Q3Point2D_Set(
  87.     TQ3Point2D                    *point2D,
  88.     float                        x, 
  89.     float                        y);
  90.  
  91. QD3D_EXPORT TQ3Param2D *Q3Param2D_Set(
  92.     TQ3Param2D                    *param2D,
  93.     float                        u, 
  94.     float                        v);
  95.  
  96. QD3D_EXPORT TQ3Point3D *Q3Point3D_Set(
  97.     TQ3Point3D                    *point3D,
  98.     float                        x, 
  99.     float                        y, 
  100.     float                        z);
  101.  
  102. QD3D_EXPORT TQ3RationalPoint3D *Q3RationalPoint3D_Set(
  103.     TQ3RationalPoint3D            *point3D,
  104.     float                        x, 
  105.     float                        y, 
  106.     float                        w);
  107.     
  108. QD3D_EXPORT TQ3RationalPoint4D *Q3RationalPoint4D_Set(
  109.     TQ3RationalPoint4D            *point4D,
  110.     float                        x,
  111.     float                        y,
  112.     float                        z, 
  113.     float                        w);
  114.     
  115. QD3D_EXPORT TQ3Vector2D *Q3Vector2D_Set(
  116.     TQ3Vector2D                    *vector2D,
  117.     float                        x, 
  118.     float                        y);
  119.  
  120. QD3D_EXPORT TQ3Vector3D *Q3Vector3D_Set(
  121.     TQ3Vector3D                    *vector3D,
  122.     float                        x, 
  123.     float                        y, 
  124.     float                        z);
  125.  
  126. QD3D_EXPORT TQ3PolarPoint *Q3PolarPoint_Set(
  127.     TQ3PolarPoint                *polarPoint,
  128.     float                        r,
  129.     float                        theta);
  130.  
  131. QD3D_EXPORT TQ3SphericalPoint *Q3SphericalPoint_Set(
  132.     TQ3SphericalPoint            *sphericalPoint,
  133.     float                        rho,
  134.     float                        theta,
  135.     float                        phi);
  136.     
  137.     
  138. /******************************************************************************
  139.  **                                                                             **
  140.  **                    Point and Vector Dimension Conversion                     **
  141.  **                                                                             **
  142.  *****************************************************************************/
  143.  
  144. QD3D_EXPORT TQ3Point3D *Q3Point2D_To3D(
  145.     const TQ3Point2D            *point2D,
  146.     TQ3Point3D                    *result);
  147.  
  148. QD3D_EXPORT TQ3Point2D *Q3RationalPoint3D_To2D(
  149.     const TQ3RationalPoint3D    *point3D,
  150.     TQ3Point2D                    *result);
  151.     
  152. QD3D_EXPORT TQ3RationalPoint4D *Q3Point3D_To4D(
  153.     const TQ3Point3D            *point3D,
  154.     TQ3RationalPoint4D            *result);
  155.  
  156. QD3D_EXPORT TQ3Point3D *Q3RationalPoint4D_To3D(
  157.     const TQ3RationalPoint4D    *point4D,
  158.     TQ3Point3D                    *result);
  159.  
  160. QD3D_EXPORT TQ3Vector3D *Q3Vector2D_To3D(
  161.     const TQ3Vector2D            *vector2D,
  162.     TQ3Vector3D                    *result);
  163.     
  164. QD3D_EXPORT TQ3Vector2D *Q3Vector3D_To2D(
  165.     const TQ3Vector3D            *vector3D,
  166.     TQ3Vector2D                    *result);
  167.  
  168.     
  169. /******************************************************************************
  170.  **                                                                             **
  171.  **                            Point Subtraction                                 **
  172.  **                                                                             **
  173.  *****************************************************************************/
  174.  
  175. QD3D_EXPORT TQ3Vector2D *Q3Point2D_Subtract(
  176.     const TQ3Point2D            *p1, 
  177.     const TQ3Point2D            *p2,
  178.     TQ3Vector2D                    *result);
  179.  
  180. QD3D_EXPORT TQ3Vector2D *Q3Param2D_Subtract(
  181.     const TQ3Param2D            *p1, 
  182.     const TQ3Param2D            *p2,
  183.     TQ3Vector2D                    *result);
  184.  
  185. QD3D_EXPORT TQ3Vector3D *Q3Point3D_Subtract(
  186.     const TQ3Point3D            *p1, 
  187.     const TQ3Point3D            *p2,
  188.     TQ3Vector3D                    *result);
  189.     
  190.     
  191. /******************************************************************************
  192.  **                                                                             **
  193.  **                            Point Distance                                     **
  194.  **                                                                             **
  195.  *****************************************************************************/
  196.     
  197. QD3D_EXPORT float Q3Point2D_Distance(
  198.     const TQ3Point2D            *p1, 
  199.     const TQ3Point2D            *p2);
  200.  
  201. QD3D_EXPORT float Q3Point2D_DistanceSquared(
  202.     const TQ3Point2D            *p1, 
  203.     const TQ3Point2D            *p2);
  204.  
  205.  
  206. QD3D_EXPORT float Q3Param2D_Distance(
  207.     const TQ3Param2D            *p1, 
  208.     const TQ3Param2D            *p2);
  209.  
  210. QD3D_EXPORT float Q3Param2D_DistanceSquared(
  211.     const TQ3Param2D            *p1, 
  212.     const TQ3Param2D            *p2);
  213.     
  214.     
  215. QD3D_EXPORT float Q3RationalPoint3D_Distance(
  216.     const TQ3RationalPoint3D    *p1, 
  217.     const TQ3RationalPoint3D    *p2);
  218.     
  219. QD3D_EXPORT float Q3RationalPoint3D_DistanceSquared(
  220.     const TQ3RationalPoint3D    *p1, 
  221.     const TQ3RationalPoint3D    *p2);
  222.  
  223.  
  224. QD3D_EXPORT float Q3Point3D_Distance(
  225.     const TQ3Point3D            *p1, 
  226.     const TQ3Point3D            *p2);
  227.  
  228. QD3D_EXPORT float Q3Point3D_DistanceSquared(
  229.     const TQ3Point3D            *p1, 
  230.     const TQ3Point3D            *p2);
  231.  
  232.  
  233. QD3D_EXPORT float Q3RationalPoint4D_Distance(
  234.     const TQ3RationalPoint4D    *p1, 
  235.     const TQ3RationalPoint4D    *p2);
  236.  
  237. QD3D_EXPORT float Q3RationalPoint4D_DistanceSquared(
  238.     const TQ3RationalPoint4D    *p1, 
  239.     const TQ3RationalPoint4D    *p2);
  240.  
  241.  
  242. /******************************************************************************
  243.  **                                                                             **
  244.  **                            Point Relative Ratio                             **
  245.  **                                                                             **
  246.  *****************************************************************************/
  247.  
  248. QD3D_EXPORT TQ3Point2D *Q3Point2D_RRatio(
  249.     const TQ3Point2D            *p1,
  250.     const TQ3Point2D            *p2,
  251.     float                        r1,
  252.     float                        r2,
  253.     TQ3Point2D                    *result);
  254.  
  255. QD3D_EXPORT TQ3Param2D *Q3Param2D_RRatio(
  256.     const TQ3Param2D            *p1,
  257.     const TQ3Param2D            *p2,
  258.     float                        r1,
  259.     float                        r2,
  260.     TQ3Param2D                    *result);
  261.  
  262. QD3D_EXPORT TQ3Point3D *Q3Point3D_RRatio(
  263.     const TQ3Point3D            *p1,
  264.     const TQ3Point3D            *p2,
  265.     float                        r1,
  266.     float                        r2,
  267.     TQ3Point3D                    *result);
  268.  
  269. QD3D_EXPORT TQ3RationalPoint4D *Q3RationalPoint4D_RRatio(
  270.     const TQ3RationalPoint4D    *p1,
  271.     const TQ3RationalPoint4D    *p2,
  272.     float                        r1,
  273.     float                        r2,
  274.     TQ3RationalPoint4D            *result);
  275.                         
  276.                         
  277. /******************************************************************************
  278.  **                                                                             **
  279.  **                    Point / Vector Addition    & Subtraction                     **
  280.  **                                                                             **
  281.  *****************************************************************************/
  282.  
  283. QD3D_EXPORT TQ3Point2D *Q3Point2D_Vector2D_Add(
  284.     const TQ3Point2D            *point2D, 
  285.     const TQ3Vector2D            *vector2D,
  286.     TQ3Point2D                    *result);
  287.  
  288. QD3D_EXPORT TQ3Param2D *Q3Param2D_Vector2D_Add(
  289.     const TQ3Param2D            *param2D, 
  290.     const TQ3Vector2D            *vector2D,
  291.     TQ3Param2D                    *result);
  292.  
  293. QD3D_EXPORT TQ3Point3D *Q3Point3D_Vector3D_Add(
  294.     const TQ3Point3D            *point3D, 
  295.     const TQ3Vector3D            *vector3D,
  296.     TQ3Point3D                    *result);
  297.  
  298. QD3D_EXPORT TQ3Point2D *Q3Point2D_Vector2D_Subtract(
  299.     const TQ3Point2D            *point2D, 
  300.     const TQ3Vector2D            *vector2D,
  301.     TQ3Point2D                    *result);
  302.  
  303. QD3D_EXPORT TQ3Param2D *Q3Param2D_Vector2D_Subtract(
  304.     const TQ3Param2D            *param2D, 
  305.     const TQ3Vector2D            *vector2D,
  306.     TQ3Param2D                    *result);
  307.  
  308. QD3D_EXPORT TQ3Point3D *Q3Point3D_Vector3D_Subtract(
  309.     const TQ3Point3D            *point3D, 
  310.     const TQ3Vector3D            *vector3D,
  311.     TQ3Point3D                    *result);
  312.  
  313.  
  314. /******************************************************************************
  315.  **                                                                             **
  316.  **                                Vector Scale                                 **
  317.  **                                                                             **
  318.  *****************************************************************************/
  319.                         
  320. QD3D_EXPORT TQ3Vector2D *Q3Vector2D_Scale(
  321.     const TQ3Vector2D            *vector2D, 
  322.     float                        scalar,
  323.     TQ3Vector2D                    *result);
  324.  
  325. QD3D_EXPORT TQ3Vector3D *Q3Vector3D_Scale(
  326.     const TQ3Vector3D            *vector3D, 
  327.     float                        scalar,
  328.     TQ3Vector3D                    *result);
  329.  
  330.     
  331. /******************************************************************************
  332.  **                                                                             **
  333.  **                                Vector Length                                 **
  334.  **                                                                             **
  335.  *****************************************************************************/
  336.  
  337. QD3D_EXPORT float Q3Vector2D_Length(
  338.     const TQ3Vector2D             *vector2D);
  339.  
  340. QD3D_EXPORT float Q3Vector3D_Length(
  341.     const TQ3Vector3D            *vector3D);
  342.  
  343.     
  344. /******************************************************************************
  345.  **                                                                             **
  346.  **                                Vector Normalize                             **
  347.  **                                                                             **
  348.  *****************************************************************************/
  349.  
  350. QD3D_EXPORT TQ3Vector2D *Q3Vector2D_Normalize(
  351.     const TQ3Vector2D            *vector2D,
  352.     TQ3Vector2D                    *result);
  353.  
  354. QD3D_EXPORT TQ3Vector3D *Q3Vector3D_Normalize(
  355.     const TQ3Vector3D            *vector3D,
  356.     TQ3Vector3D                    *result);
  357.  
  358.  
  359. /******************************************************************************
  360.  **                                                                             **
  361.  **                    Vector/Vector Addition and Subtraction                     **
  362.  **                                                                             **
  363.  *****************************************************************************/
  364.  
  365. QD3D_EXPORT TQ3Vector2D *Q3Vector2D_Add(
  366.     const TQ3Vector2D            *v1, 
  367.     const TQ3Vector2D            *v2,
  368.     TQ3Vector2D                    *result);
  369.  
  370. QD3D_EXPORT TQ3Vector3D *Q3Vector3D_Add(
  371.     const TQ3Vector3D            *v1, 
  372.     const TQ3Vector3D            *v2, 
  373.     TQ3Vector3D                    *result);
  374.  
  375.  
  376. QD3D_EXPORT TQ3Vector2D *Q3Vector2D_Subtract(
  377.     const TQ3Vector2D            *v1, 
  378.     const TQ3Vector2D            *v2, 
  379.     TQ3Vector2D                    *result);
  380.  
  381. QD3D_EXPORT TQ3Vector3D *Q3Vector3D_Subtract(
  382.     const TQ3Vector3D            *v1, 
  383.     const TQ3Vector3D            *v2,
  384.     TQ3Vector3D                    *result);
  385.  
  386.  
  387. /******************************************************************************
  388.  **                                                                             **
  389.  **                                Cross Product                                 **
  390.  **                                                                             **
  391.  *****************************************************************************/
  392.  
  393. QD3D_EXPORT float Q3Vector2D_Cross(
  394.     const TQ3Vector2D            *v1, 
  395.     const TQ3Vector2D            *v2);
  396.  
  397. QD3D_EXPORT TQ3Vector3D *Q3Vector3D_Cross(
  398.     const TQ3Vector3D            *v1, 
  399.     const TQ3Vector3D            *v2,
  400.     TQ3Vector3D                    *result);
  401.     
  402. QD3D_EXPORT TQ3Vector3D *Q3Point3D_CrossProductTri(
  403.     const TQ3Point3D             *point1, 
  404.     const TQ3Point3D             *point2, 
  405.     const TQ3Point3D             *point3, 
  406.     TQ3Vector3D                 *crossVector);
  407.  
  408.  
  409. /******************************************************************************
  410.  **                                                                             **
  411.  **                                Dot Product                                     **
  412.  **                                                                             **
  413.  *****************************************************************************/
  414.  
  415. QD3D_EXPORT float Q3Vector2D_Dot(
  416.     const TQ3Vector2D            *v1, 
  417.     const TQ3Vector2D            *v2);
  418.  
  419. QD3D_EXPORT float Q3Vector3D_Dot(
  420.     const TQ3Vector3D            *v1, 
  421.     const TQ3Vector3D            *v2);
  422.  
  423.  
  424. /******************************************************************************
  425.  **                                                                             **
  426.  **                        Point and Vector Transformation                         **
  427.  **                                                                             **
  428.  *****************************************************************************/
  429.  
  430. QD3D_EXPORT TQ3Vector2D *Q3Vector2D_Transform(
  431.     const TQ3Vector2D            *vector2D,
  432.     const TQ3Matrix3x3             *matrix3x3,
  433.     TQ3Vector2D                    *result);
  434.     
  435. QD3D_EXPORT TQ3Vector3D *Q3Vector3D_Transform(
  436.     const TQ3Vector3D            *vector3D,
  437.     const TQ3Matrix4x4            *matrix4x4,
  438.     TQ3Vector3D                    *result);
  439.  
  440. QD3D_EXPORT TQ3Point2D *Q3Point2D_Transform(
  441.     const TQ3Point2D             *point2D,
  442.     const TQ3Matrix3x3            *matrix3x3,
  443.     TQ3Point2D                    *result);
  444.  
  445. QD3D_EXPORT TQ3Param2D *Q3Param2D_Transform(
  446.     const TQ3Param2D             *param2D,
  447.     const TQ3Matrix3x3            *matrix3x3,
  448.     TQ3Param2D                    *result);
  449.  
  450. QD3D_EXPORT TQ3Point3D *Q3Point3D_Transform(
  451.     const TQ3Point3D            *point3D,
  452.     const TQ3Matrix4x4            *matrix4x4,
  453.     TQ3Point3D                    *result);
  454.  
  455. QD3D_EXPORT TQ3RationalPoint4D *Q3RationalPoint4D_Transform(
  456.     const TQ3RationalPoint4D    *point4D, 
  457.     const TQ3Matrix4x4            *matrix4x4,
  458.     TQ3RationalPoint4D            *result);
  459.     
  460. QD3D_EXPORT TQ3Status Q3Point3D_To3DTransformArray(
  461.     const TQ3Point3D             *inVertex, 
  462.     const TQ3Matrix4x4             *matrix,
  463.     TQ3Point3D                     *outVertex,  
  464.     long                         numVertices, 
  465.     unsigned long                 inStructSize, 
  466.     unsigned long                 outStructSize);
  467.     
  468. QD3D_EXPORT TQ3Status Q3Point3D_To4DTransformArray(
  469.     const TQ3Point3D             *inVertex, 
  470.     const TQ3Matrix4x4             *matrix,
  471.     TQ3RationalPoint4D             *outVertex,  
  472.     long                         numVertices,
  473.     unsigned long                 inStructSize, 
  474.     unsigned long                 outStructSize);
  475.     
  476. QD3D_EXPORT TQ3Status Q3RationalPoint4D_To4DTransformArray(
  477.     const TQ3RationalPoint4D     *inVertex, 
  478.     const TQ3Matrix4x4             *matrix,
  479.     TQ3RationalPoint4D             *outVertex,  
  480.     long                         numVertices, 
  481.     unsigned long                 inStructSize, 
  482.     unsigned long                 outStructSize);
  483.  
  484.  
  485. /******************************************************************************
  486.  **                                                                             **
  487.  **                                Vector Negation                                 **
  488.  **                                                                             **
  489.  *****************************************************************************/
  490.  
  491. QD3D_EXPORT TQ3Vector2D *Q3Vector2D_Negate(
  492.     const TQ3Vector2D            *vector2D,
  493.     TQ3Vector2D                    *result);
  494.  
  495. QD3D_EXPORT TQ3Vector3D *Q3Vector3D_Negate(
  496.     const TQ3Vector3D            *vector3D,
  497.     TQ3Vector3D                    *result);
  498.  
  499.  
  500. /******************************************************************************
  501.  **                                                                             **
  502.  **                    Point conversion from cartesian to polar                 **
  503.  **                                                                             **
  504.  *****************************************************************************/
  505.  
  506. QD3D_EXPORT TQ3PolarPoint *Q3Point2D_ToPolar(
  507.     const TQ3Point2D            *point2D,
  508.     TQ3PolarPoint                *result);
  509.     
  510. QD3D_EXPORT TQ3Point2D *Q3PolarPoint_ToPoint2D(
  511.     const TQ3PolarPoint            *polarPoint,
  512.     TQ3Point2D                    *result);
  513.     
  514. QD3D_EXPORT TQ3SphericalPoint *Q3Point3D_ToSpherical(
  515.     const TQ3Point3D            *point3D,
  516.     TQ3SphericalPoint            *result);
  517.     
  518. QD3D_EXPORT TQ3Point3D *Q3SphericalPoint_ToPoint3D(
  519.     const TQ3SphericalPoint        *sphericalPoint,
  520.     TQ3Point3D                    *result);
  521.  
  522.  
  523. /******************************************************************************
  524.  **                                                                             **
  525.  **                            Point Affine Combinations                         **
  526.  **                                                                             **
  527.  *****************************************************************************/
  528.  
  529. QD3D_EXPORT TQ3Point2D *Q3Point2D_AffineComb(
  530.     const TQ3Point2D            *points2D,
  531.     const float                    *weights,
  532.     unsigned long                nPoints, 
  533.     TQ3Point2D                    *result);
  534.  
  535. QD3D_EXPORT TQ3Param2D *Q3Param2D_AffineComb(
  536.     const TQ3Param2D            *param2Ds,
  537.     const float                    *weights,
  538.     unsigned long                nPoints, 
  539.     TQ3Param2D                    *result);
  540.  
  541. QD3D_EXPORT TQ3RationalPoint3D *Q3RationalPoint3D_AffineComb(
  542.     const TQ3RationalPoint3D    *points3D,
  543.     const float                    *weights,
  544.     unsigned long                nPoints, 
  545.     TQ3RationalPoint3D            *result);
  546.     
  547. QD3D_EXPORT TQ3Point3D *Q3Point3D_AffineComb(
  548.     const TQ3Point3D            *points3D,
  549.     const float                    *weights,
  550.     unsigned long                nPoints, 
  551.     TQ3Point3D                    *result);
  552.  
  553. QD3D_EXPORT TQ3RationalPoint4D *Q3RationalPoint4D_AffineComb(
  554.     const TQ3RationalPoint4D    *points4D,
  555.     const float                    *weights,
  556.     unsigned long                nPoints, 
  557.     TQ3RationalPoint4D            *result);
  558.     
  559.     
  560. /******************************************************************************
  561.  **                                                                             **
  562.  **                                Matrix Functions                             **
  563.  **                                                                             **
  564.  *****************************************************************************/
  565.  
  566. QD3D_EXPORT TQ3Matrix3x3 *Q3Matrix3x3_Copy(
  567.     const TQ3Matrix3x3            *matrix3x3,
  568.     TQ3Matrix3x3                *result);
  569.     
  570. QD3D_EXPORT TQ3Matrix4x4 *Q3Matrix4x4_Copy(
  571.     const TQ3Matrix4x4            *matrix4x4,
  572.     TQ3Matrix4x4                *result);
  573.  
  574.  
  575. QD3D_EXPORT TQ3Matrix3x3 *Q3Matrix3x3_SetIdentity(
  576.     TQ3Matrix3x3                *matrix3x3);
  577.  
  578. QD3D_EXPORT TQ3Matrix4x4 *Q3Matrix4x4_SetIdentity(
  579.     TQ3Matrix4x4                *matrix4x4);
  580.  
  581.  
  582. QD3D_EXPORT TQ3Matrix3x3 *Q3Matrix3x3_Transpose(
  583.     const TQ3Matrix3x3            *matrix3x3,
  584.     TQ3Matrix3x3                *result);
  585.  
  586. QD3D_EXPORT TQ3Matrix4x4 *Q3Matrix4x4_Transpose(
  587.     const TQ3Matrix4x4            *matrix4x4,
  588.     TQ3Matrix4x4                *result);
  589.  
  590.  
  591. QD3D_EXPORT TQ3Matrix3x3 *Q3Matrix3x3_Invert(
  592.     const TQ3Matrix3x3            *matrix3x3,
  593.     TQ3Matrix3x3                *result);
  594.  
  595. QD3D_EXPORT TQ3Matrix4x4 *Q3Matrix4x4_Invert(
  596.     const TQ3Matrix4x4            *matrix4x4,
  597.     TQ3Matrix4x4                *result);
  598.     
  599.     
  600. QD3D_EXPORT TQ3Matrix3x3 *Q3Matrix3x3_Adjoint(
  601.     const TQ3Matrix3x3            *matrix3x3,
  602.     TQ3Matrix3x3                *result);
  603.  
  604.  
  605. QD3D_EXPORT TQ3Matrix3x3 *Q3Matrix3x3_Multiply(
  606.     const TQ3Matrix3x3            *matrixA,
  607.     const TQ3Matrix3x3            *matrixB,
  608.     TQ3Matrix3x3                *result);
  609.  
  610. QD3D_EXPORT TQ3Matrix4x4 *Q3Matrix4x4_Multiply(
  611.     const TQ3Matrix4x4            *matrixA,
  612.     const TQ3Matrix4x4            *matrixB,
  613.     TQ3Matrix4x4                *result);
  614.  
  615.  
  616. QD3D_EXPORT TQ3Matrix3x3 *Q3Matrix3x3_SetTranslate(
  617.     TQ3Matrix3x3                *matrix3x3,    
  618.     float                        xTrans,
  619.     float                        yTrans);
  620.  
  621. QD3D_EXPORT TQ3Matrix3x3 *Q3Matrix3x3_SetScale(
  622.     TQ3Matrix3x3                *matrix3x3,
  623.     float                        xScale,
  624.     float                        yScale);
  625.  
  626.  
  627. QD3D_EXPORT TQ3Matrix3x3 *Q3Matrix3x3_SetRotateAboutPoint(
  628.     TQ3Matrix3x3                *matrix3x3,
  629.     const TQ3Point2D            *origin,
  630.     float                        angle);
  631.  
  632. QD3D_EXPORT TQ3Matrix4x4 *Q3Matrix4x4_SetTranslate(
  633.     TQ3Matrix4x4                *matrix4x4,
  634.     float                        xTrans,
  635.     float                        yTrans,
  636.     float                        zTrans);
  637.  
  638. QD3D_EXPORT TQ3Matrix4x4 *Q3Matrix4x4_SetScale(
  639.     TQ3Matrix4x4                *matrix4x4,
  640.     float                        xScale,
  641.     float                        yScale,
  642.     float                        zScale);
  643.  
  644.  
  645. QD3D_EXPORT TQ3Matrix4x4 *Q3Matrix4x4_SetRotateAboutPoint(
  646.     TQ3Matrix4x4                *matrix4x4,
  647.     const TQ3Point3D            *origin,
  648.     float                        xAngle,
  649.     float                        yAngle,
  650.     float                        zAngle);
  651.     
  652. QD3D_EXPORT TQ3Matrix4x4 *Q3Matrix4x4_SetRotateAboutAxis(
  653.     TQ3Matrix4x4                *matrix4x4,
  654.     const TQ3Point3D            *origin,
  655.     const TQ3Vector3D            *orientation,   
  656.     float                        angle);    
  657.     
  658. QD3D_EXPORT TQ3Matrix4x4 *Q3Matrix4x4_SetRotate_X(
  659.     TQ3Matrix4x4                *matrix4x4,
  660.     float                        angle);
  661.     
  662. QD3D_EXPORT TQ3Matrix4x4 *Q3Matrix4x4_SetRotate_Y(
  663.     TQ3Matrix4x4                *matrix4x4,
  664.     float                        angle);
  665.  
  666. QD3D_EXPORT TQ3Matrix4x4 *Q3Matrix4x4_SetRotate_Z(
  667.     TQ3Matrix4x4                *matrix4x4,
  668.     float                        angle);
  669.         
  670. QD3D_EXPORT TQ3Matrix4x4 *Q3Matrix4x4_SetRotate_XYZ(
  671.     TQ3Matrix4x4                *matrix4x4,
  672.     float                        xAngle,
  673.     float                        yAngle,
  674.     float                        zAngle);                            
  675.                             
  676. QD3D_EXPORT TQ3Matrix4x4 *Q3Matrix4x4_SetRotateVectorToVector(
  677.     TQ3Matrix4x4                *matrix4x4,
  678.     const TQ3Vector3D            *v1,
  679.     const TQ3Vector3D            *v2);
  680.  
  681. QD3D_EXPORT TQ3Matrix4x4 *Q3Matrix4x4_SetQuaternion(
  682.     TQ3Matrix4x4                 *matrix, 
  683.     const TQ3Quaternion         *quaternion);
  684.  
  685. QD3D_EXPORT float Q3Matrix3x3_Determinant(
  686.     const TQ3Matrix3x3            *matrix3x3);
  687.  
  688. QD3D_EXPORT float Q3Matrix4x4_Determinant(
  689.     const TQ3Matrix4x4            *matrix4x4);
  690.     
  691.     
  692. /******************************************************************************
  693.  **                                                                             **
  694.  **                                Quaternion Routines                             **
  695.  **                                                                             **
  696.  *****************************************************************************/
  697.  
  698. QD3D_EXPORT TQ3Quaternion *Q3Quaternion_Set(
  699.     TQ3Quaternion                *quaternion,
  700.     float                        w,
  701.     float                        x,
  702.     float                        y,
  703.     float                        z);
  704.     
  705. QD3D_EXPORT TQ3Quaternion *Q3Quaternion_SetIdentity(
  706.     TQ3Quaternion                *quaternion);
  707.     
  708. QD3D_EXPORT TQ3Quaternion *Q3Quaternion_Copy(
  709.     const TQ3Quaternion            *quaternion, 
  710.     TQ3Quaternion                 *result);
  711.  
  712. QD3D_EXPORT TQ3Boolean Q3Quaternion_IsIdentity(
  713.     const TQ3Quaternion            *quaternion);
  714.  
  715. QD3D_EXPORT TQ3Quaternion *Q3Quaternion_Invert(
  716.     const TQ3Quaternion         *quaternion,
  717.     TQ3Quaternion                *result);
  718.  
  719. QD3D_EXPORT TQ3Quaternion *Q3Quaternion_Normalize(
  720.     const TQ3Quaternion            *quaternion,
  721.     TQ3Quaternion                *result);
  722.  
  723. QD3D_EXPORT float Q3Quaternion_Dot(
  724.     const TQ3Quaternion         *q1, 
  725.     const TQ3Quaternion         *q2);
  726.  
  727. QD3D_EXPORT TQ3Quaternion *Q3Quaternion_Multiply(
  728.     const TQ3Quaternion            *q1, 
  729.     const TQ3Quaternion            *q2,
  730.     TQ3Quaternion                *result);
  731.  
  732. QD3D_EXPORT TQ3Quaternion *Q3Quaternion_SetRotateAboutAxis(
  733.     TQ3Quaternion                 *quaternion, 
  734.     const TQ3Vector3D             *axis, 
  735.     float                         angle);
  736.     
  737. QD3D_EXPORT TQ3Quaternion *Q3Quaternion_SetRotateXYZ(
  738.     TQ3Quaternion                 *quaternion, 
  739.     float                         xAngle, 
  740.     float                         yAngle, 
  741.     float                         zAngle);
  742.     
  743. QD3D_EXPORT TQ3Quaternion *Q3Quaternion_SetRotateX(
  744.     TQ3Quaternion                 *quaternion, 
  745.     float                         angle);
  746.  
  747. QD3D_EXPORT TQ3Quaternion *Q3Quaternion_SetRotateY(
  748.     TQ3Quaternion                 *quaternion, 
  749.     float                         angle);
  750.  
  751. QD3D_EXPORT TQ3Quaternion *Q3Quaternion_SetRotateZ(
  752.     TQ3Quaternion                 *quaternion, 
  753.     float                         angle);
  754.  
  755. QD3D_EXPORT TQ3Quaternion *Q3Quaternion_SetMatrix(
  756.     TQ3Quaternion                 *quaternion, 
  757.     const TQ3Matrix4x4             *matrix);
  758.  
  759. QD3D_EXPORT TQ3Quaternion *Q3Quaternion_SetRotateVectorToVector(
  760.     TQ3Quaternion                 *quaternion, 
  761.     const TQ3Vector3D             *v1, 
  762.     const TQ3Vector3D             *v2);
  763.  
  764. QD3D_EXPORT TQ3Quaternion *Q3Quaternion_MatchReflection(
  765.     const TQ3Quaternion            *q1, 
  766.     const TQ3Quaternion         *q2,
  767.     TQ3Quaternion                *result);
  768.  
  769. QD3D_EXPORT TQ3Quaternion *Q3Quaternion_InterpolateFast(
  770.     const TQ3Quaternion         *q1, 
  771.     const TQ3Quaternion         *q2, 
  772.     float                         t,
  773.     TQ3Quaternion                *result);
  774.  
  775. QD3D_EXPORT TQ3Quaternion *Q3Quaternion_InterpolateLinear(
  776.     const TQ3Quaternion         *q1, 
  777.     const TQ3Quaternion         *q2, 
  778.     float                         t,
  779.     TQ3Quaternion                 *result);
  780.  
  781. QD3D_EXPORT TQ3Vector3D *Q3Vector3D_TransformQuaternion(
  782.     const TQ3Vector3D             *vector, 
  783.     const TQ3Quaternion         *quaternion,
  784.     TQ3Vector3D                    *result);
  785.  
  786. QD3D_EXPORT TQ3Point3D *Q3Point3D_TransformQuaternion(
  787.     const TQ3Point3D             *vector, 
  788.     const TQ3Quaternion         *quaternion,
  789.     TQ3Point3D                    *result);
  790.  
  791.  
  792. /******************************************************************************
  793.  **                                                                             **
  794.  **                                Volume Routines                                 **
  795.  **                                                                             **
  796.  *****************************************************************************/
  797.  
  798. QD3D_EXPORT TQ3BoundingBox *Q3BoundingBox_Copy(
  799.     const TQ3BoundingBox         *src, 
  800.     TQ3BoundingBox                 *dest);
  801.     
  802. QD3D_EXPORT TQ3BoundingBox *Q3BoundingBox_Union(
  803.     const TQ3BoundingBox         *v1, 
  804.     const TQ3BoundingBox         *v2,
  805.     TQ3BoundingBox                *result);
  806.     
  807. QD3D_EXPORT TQ3BoundingBox *Q3BoundingBox_Set(
  808.     TQ3BoundingBox                 *bBox,
  809.     const TQ3Point3D             *min, 
  810.     const TQ3Point3D             *max,
  811.     TQ3Boolean                    isEmpty);
  812.     
  813. QD3D_EXPORT TQ3BoundingBox *Q3BoundingBox_UnionPoint3D(
  814.     const TQ3BoundingBox         *bBox,
  815.     const TQ3Point3D             *pt3D,
  816.     TQ3BoundingBox                *result);
  817.     
  818. QD3D_EXPORT TQ3BoundingBox *Q3BoundingBox_UnionRationalPoint4D(
  819.     const TQ3BoundingBox         *bBox,
  820.     const TQ3RationalPoint4D     *pt4D, 
  821.     TQ3BoundingBox                 *result);
  822.  
  823. QD3D_EXPORT TQ3BoundingBox *Q3BoundingBox_SetFromPoints3D(
  824.     TQ3BoundingBox                 *bBox, 
  825.     const TQ3Point3D             *pts, 
  826.     unsigned long                 nPts,
  827.     unsigned long                structSize);
  828.     
  829. QD3D_EXPORT TQ3BoundingBox *Q3BoundingBox_SetFromRationalPoints4D(
  830.     TQ3BoundingBox                 *bBox, 
  831.     const TQ3RationalPoint4D     *pts, 
  832.     unsigned long                 nPts,
  833.     unsigned long                structSize);
  834.  
  835.  
  836. /******************************************************************************
  837.  **                                                                             **
  838.  **                                Sphere Routines                                 **
  839.  **                                                                             **
  840.  *****************************************************************************/
  841.  
  842. QD3D_EXPORT TQ3BoundingSphere *Q3BoundingSphere_Copy(
  843.     const TQ3BoundingSphere     *src, 
  844.     TQ3BoundingSphere             *dest);
  845.     
  846. QD3D_EXPORT TQ3BoundingSphere *Q3BoundingSphere_Union(
  847.     const TQ3BoundingSphere     *s1, 
  848.     const TQ3BoundingSphere     *s2,
  849.     TQ3BoundingSphere            *result);
  850.  
  851. QD3D_EXPORT TQ3BoundingSphere *Q3BoundingSphere_Set(
  852.     TQ3BoundingSphere             *bSphere,
  853.     const TQ3Point3D             *origin, 
  854.     float                        radius,
  855.     TQ3Boolean                    isEmpty);
  856.     
  857. QD3D_EXPORT TQ3BoundingSphere *Q3BoundingSphere_UnionPoint3D(
  858.     const TQ3BoundingSphere     *bSphere,
  859.     const TQ3Point3D             *pt3D,
  860.     TQ3BoundingSphere            *result);
  861.     
  862. QD3D_EXPORT TQ3BoundingSphere *Q3BoundingSphere_UnionRationalPoint4D(
  863.     const TQ3BoundingSphere     *bSphere,
  864.     const TQ3RationalPoint4D     *pt4D, 
  865.     TQ3BoundingSphere             *result);
  866.  
  867.     
  868. QD3D_EXPORT TQ3BoundingSphere *Q3BoundingSphere_SetFromPoints3D(
  869.     TQ3BoundingSphere             *bSphere, 
  870.     const TQ3Point3D             *pts, 
  871.     unsigned long                 nPts,
  872.     unsigned long                structSize);
  873.     
  874. QD3D_EXPORT TQ3BoundingSphere *Q3BoundingSphere_SetFromRationalPoints4D(
  875.     TQ3BoundingSphere             *bSphere, 
  876.     const TQ3RationalPoint4D     *pts, 
  877.     unsigned long                 nPts,
  878.     unsigned long                structSize);    
  879.  
  880.  
  881. #ifdef __cplusplus
  882. }
  883. #endif    /* __cplusplus */
  884.  
  885. #if defined(__MWERKS__)
  886. #pragma options align=reset
  887. #pragma enumsalwaysint reset
  888. #endif
  889.  
  890. #endif  /*  QD3DMath_h  */
  891.